function GetDate(day, type) {    

	var zdate = new Date();    

	var edate;    

	if (type == 1) {        

		edate = new Date(zdate.getTime() - (day * 24 * 60 * 60 * 1000));    

	} else {        

		edate = new Date(zdate.getTime() + (day * 24 * 60 * 60 * 1000));   

	}    

	return edate;

}

function getDaysInMonth(year, month) {    

	month = parseInt(month, 10) + 1;    

	var temp = new Date(year + "/" + month + "/0");    

	return temp.getDate();

}

function isWeek (date) {

    var date1 = new Date(date.replace(/-/g, "/"));         //将传入的时间字符串转换成时间对象    

	var date2 = new Date();     //当前时间    

	var curWeek = date2.getDay();           //获取当前星期几
		
	if(curWeek === 0) curWeek = 7

	var monday = GetDate((curWeek), 1); //计算出星期一    

	var sunday = GetDate((7 - curWeek), 2); //计算出星期天

		if (date1.getTime() < monday.setHours(23, 59 ,59 ,0) || date1.getTime() > sunday.setHours(23, 59 ,59 ,0)) {        

	return false;       //不在同一个星期内    

	} else {        

	return true;        //在同一个星期内    

	}

  }

function isMonth(date) {    

	var date1 = new Date(date.replace(/-/g, "/"));         //将传入的时间字符串转换成时间对象    

	var date2 = new Date();     　　　　   //当前时间    

	var curDay = date2.getDate();           //获取当前几号    

	var firstDay = GetDate((curDay), 1);                                //计算出当月第一天    

	var lastDay = GetDate((getDaysInMonth(date2.getFullYear(), date2.getMonth() + 1) - curDay), 2);    //计算出当月最后一天

		if (date1.getTime() < firstDay.getTime() || date1.getTime() > lastDay.getTime()) {        

	return false;       //不在同一个月内    

	} else {        

	return true;        //在同一个月内    

	}

}


export {
	isWeek,
	isMonth
}